Solved Using Android Studio in Java language. Write the code 您所在的位置:网站首页 android studio language Solved Using Android Studio in Java language. Write the code

Solved Using Android Studio in Java language. Write the code

#Solved Using Android Studio in Java language. Write the code | 来源: 网络整理| 查看: 265

Using Android Studio in Java language. Write the code .

MyListAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast;

public class MyListAdapter extends RecyclerView.Adapter;MyListAdapter.ViewHolder;{ private MyListData[] listdata;

// RecyclerView recyclerView; public MyListAdapter(MyListData[] listdata) { this.listdata = listdata; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); View listItem= layoutInflater.inflate(R.layout.list_item, parent, false); ViewHolder viewHolder = new ViewHolder(listItem);

4

return viewHolder; }

@Override public void onBindViewHolder(ViewHolder holder, int position) { final MyListData myListData = listdata[position]; holder.textView.setText(listdata[position].getDescription()); holder.imageView.setImageResource(listdata[position].getImgId()); holder.relativeLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(view.getContext(),;click on item: ;+myListData.getDescription(),Toast.LENG TH_LONG).show(); } }); }

@Override public int getItemCount() { return listdata.length; }

public static class ViewHolder extends RecyclerView.ViewHolder { public ImageView imageView; public TextView textView; public RelativeLayout relativeLayout; public ViewHolder(View itemView) { super(itemView); this.imageView = (ImageView) itemView.findViewById(R.id.imageView); this.textView = (TextView) itemView.findViewById(R.id.textView); relativeLayout = (RelativeLayout)itemView.findViewById(R.id.relativeLayout); } } }

Following are some scenarios that you have to implement keeping in mind Activities, Intents and now Recycler View. 1. First of all you have to create a login page. You must mention the authentication code at the backend. This will only allow the valid user to login to the application. 2. Once the user is logged in, you have to display a list of restaurants using recycler view. The user can select any restaurant and view the menu of that specific restaurant for food ordering purposes. 3. Once the user has viewed the desired menu, allow the user to logout from the application.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有